<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>选择运价方案choosePricePlan</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<link rel="stylesheet" href="../css/less/common_less.css" />
	<style>
		
		input{
			font-family:"微软雅黑";
		}
		.Dolo_searchPanle p{
			line-height:50px;			
		}
		.Dolo_searchPanle p span{
			margin-left:20px;
		}
		.Dolo_searchPanle p span input{
			margin-left:5px;
			height:21px;
			border:1px solid #e1e1eb;
			border-radius:3px;
		}
		.Dolo_btn{
			float:right;
			margin-right:20px;
			margin-top:12px;
		}
		.querySpan{
			float:right;
			margin-right:20px;
			margin-top:12px;
		}
		.checkPanle{
			width:1140px;
			height:47px;
			margin-left:4px;			
		}
		.checkPanle p{
			line-height:46px;
		}
		.checkPanle p span:first-child{
			margin-left:20px;
		}
		.checkPanle p span:first-child input{
			position:relative;
			top:5px;
		}
		.dataTable{
			background:white;
			margin-left:4px;
			width:1140px;
		}
		.dataTable table th:nth-of-type(1){
			width:250px;
		}
		.dataTable table{
			border-collapse:collapse;
			width:1140px;
		}
		.dataTable table td{
			height:40px;
		}
		.dataTable table tr th{
			font-weight:normal;
		}
		.dataTable .clear tr{
			border-top:5px solid #f1f1f1;
		}
		.topTr{
			height:38px;
			background:white;
			border-top:1px solid #f1f1f1;
			border-bottom:1px solid #f1f1f1;
		}
		.check{
			float:left;
			margin-left:20px;
		}
	</style>
	<body>
		<div class='Dolo_searchPanle f60666'>
			<p>
				<span>运价方案编号<input class='planNumber' type='text'/></span>
				<span>方案开始日期<input class='datespicker planStartDate' onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'})" type='text'/></span>
				<span>方案结束日期<input class='datespicker planEndDate' onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'})" type='text'/></span>				
			<!-- 	<button class='Dolo_btn query'>查询</button>  -->
			  	<button class="querySpan query searchBtn"><i class="iconfont setIcon">&#xe661;</i>查询</button> 
			</p>
		</div>
		<div class='checkPanle'>
			<p>
			<!-- 	<span><input class='checkAll' type='checkbox'/> &nbsp;全选</span> -->
				<span><button class='Dolo_btn choosePlan'>选择运价</button></span>
			</p>
		</div>
		<div class='dataTable'>
			<table id="dataTable">
				<thead>
					<tr class='topTr f868686'>
						<th>运价方案编号</th>
						<th>方案开始日期</th>
						<th>方案结束日期</th>
						<th>方案类型</th>
						<th>舱位</th>
					</tr>	
				</thead>
				<tbody class='clear'></tbody>			
			</table>
		</div>
		<!-- 分页 -->
		<div class='Pagination'></div>
	</body>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../js/jquery.freezeheader.js" ></script>
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<!-- 引入my97日期时间控件 -->
		<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>	
		<script>
			$(".query").click(function(){
				$(".page").val("1");
				getAjax();
			})
			
			//_____________________________________________________________页面渲染
				
			//_____________________________________________________________封装ajax
			var totalAmount;
			var totalPage;
			var nowPage;
			function getAjax(){
				var number=$(".planNumber").val();//方案编号
				var startDate=$(".planStartDate").val();//开始日期
				var endDate=$(".planEndDate").val();//结束日期
				var pageNum = $(".page").val();
				var pageSize = $(".pageSize").val();
				var free = getHref().free;
				var isFreeType = free?true:false;
				$.ajax({
					type:"get",
					url:"../fareplan/fareplanList?isFreeType="+isFreeType+"&number="+number+"&startDate="+startDate+"&endDate="+endDate+"&pageNum="+pageNum+"&pageSize="+pageSize+"&temp="+Math.random(),					
					dataType:"json",
					async:true,
					success:function(data){						
						console.log(data)
						totalAmount = data.data.total;
						totalPage = data.data.pages;
						nowPage = data.data.pageNum;
						//共多少条
						$(".totalAmount").text(totalAmount);
						//共多少页
						$(".totalPage").text(totalPage);
						//第几页
						$(".nowPage").text(nowPage);
						$(".clear").empty();
						var str="";
						for(var i=0;i<data.data.list.length;i++){
							var len=data.data.list[i].fareplans.length;
							for(var j=0;j<len;j++){								
								if(j==0){
									if(data.data.list[i].isFreeType){
										str+='<tr>'+
										'<td class="f60666" rowspan='+len+'><input class=check type=radio name=price/><span class="number">'+data.data.list[i].number+'</span><span class="freeTicketSign">免票</span></td>'
									}else{
										str+='<tr>'+
										'<td class="f60666" rowspan='+len+'><input class=check type=radio name=price/><span class="number">'+data.data.list[i].number+'</span></td>'
									}
																		
								}else{
									
									str+=""
								}																	
								str+='<td class="f60666">'+data.data.list[i].fareplans[j].startDate+'</td>'+
									 '<td class="f60666">'+data.data.list[i].fareplans[j].endDate+'</td>'+
									 '<td class="f60666">'+commomFun.typeStatusStr(data.data.list[i].fareplans[j].type)+'</td>'+
									 '<td class="f60666">'+commomFun.cabinStatusStr(data.data.list[i].fareplans[j].cabin)+'</td>'+									 
									 '</tr>';
							}
							
						}
						$(".clear").append(str);
						
					}
				})
			}

			$(".choosePlan").click(function(){	
				var number = $("input[type=radio]:checked").parent().find(".number").text()
				if(number==''){
					layer.msg('请选择运价方案', {icon: 2,time:2000},function(){
						return false;
					})
				}else{					
					if(getHref().free&&getHref().free=="free"){
						window.parent.choosePlanFree(number);
					}else{
						window.parent.choosePlan(number);
					}
					layer.msg('选择运价方案成功', {icon: 1,time:1000},function(){
						var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
						parent.layer.close(index);//关闭弹窗	
					})
				}				
			})
//________________________________________表头固定____________________________________________
		$("#dataTable").freezeHeader();		
//___________________________________________分页______________________________________________
		$(".Pagination").load("Pagination.html",function(){
			getAjax()
		})
		</script>		
</html>
